import { Injectable } from '@angular/core';
import { Resolve, ActivatedRouteSnapshot } from '@angular/router';
import { AdminModel, AdminService } from './admin.service';

@Injectable({
	providedIn: 'root',
})
export class EditService implements Resolve<AdminModel> {
	constructor(private adminService: AdminService) {}

	async resolve(route: ActivatedRouteSnapshot) {
		const admin_id = Number(route.queryParamMap.get('id'));
		return this.adminService.get(admin_id);
	}
}
